
use crate::models::teacher::TeacherModel;
use mysql::prelude::Queryable;
use rocket::serde::json::Json;
use rocket::Error;

pub struct TeacherService;

impl TeacherService {
    pub fn add(param: Json<TeacherModel>) -> Result<bool, Error> {
        TeacherModel::add(param)
    }

    pub fn query(param: Json<TeacherModel>) -> Result<Vec<TeacherModel>, Error> {
        let teachers = TeacherModel::query(param);
        teachers
    }

    pub fn query_by_pk(id: i32) -> Result<Option<TeacherModel>, Error> {
        let teachers = TeacherModel::query_by_pk(id);
        teachers
    }

    pub fn update(param: Json<TeacherModel>) -> Result<bool, Error> {
        TeacherModel::update(param)
    }

    pub fn delete(id:i32) -> Result<bool, Error> {
        TeacherModel::delete(id)
    }
}

